﻿
using System;
using System.Collections.ObjectModel;
using System.IO;
using ProtoBuf;
using SharedResources.Model;

namespace SharedResources.Utilities
{
    public static class SaveCurrent
    {

        public static bool NeedsSaving; //just does it all need saving or not

        public static string SaveLocation; //blah/blah/blah
        public static string FileNameToSave; //something .bin

        public static void SaveAsData()
        {
            WriteFileToDisk(UnderlyingData.SelectableData);
        }


        //haven;t figured out how to update an already saved file other than completely rewriting it


        private static void WriteFileToDisk(ObservableCollection<Tuple<String, SelectableDataset>> datasetToWrite)
        {
            using (var file = File.Create(Path.Combine(SaveLocation, FileNameToSave)))
            {
                Serializer.Serialize(file, datasetToWrite);
            }
        }


    }
}
